//
//  Untitled.swift
//  Mediaplayer
//
//  Created by bin hu on 2025/7/8.
//

import Foundation
import UIKit

let SCREEN_WIDTH = UIScreen.main.bounds.size.width
let SCREEN_HEIGHT = UIScreen.main.bounds.size.height
// 状态栏高度
let STATUS_BAR:CGFloat = CustomTools.getStatuHeight()
// 导航栏高度
let Nav_HEIGHT:CGFloat = (STATUS_BAR + 44.0)
// 屏幕底部安全区域高度
let BOTTOM_HEIGHT:CGFloat = CustomTools.getBottomHeight()
let TAB_HEIGHT:CGFloat = (49.0 + BOTTOM_HEIGHT)

struct CustomTools {
    // 获取顶部状态栏高度
    static func getStatuHeight() -> CGFloat {
        if #available(iOS 13.0, *) {
            let set:NSSet = UIApplication.shared.connectedScenes as NSSet
            let windowScene:UIWindowScene = set.anyObject() as! UIWindowScene
            let statusBarManager = windowScene.statusBarManager
            return statusBarManager?.statusBarFrame.height ?? 20.0
        } else {
            return UIApplication.shared.statusBarFrame.height
        }
    }
    
    // 获取底部安全区域高度
    static func getBottomHeight() -> CGFloat {
        if #available(iOS 13.0, *) {
            let set:NSSet = UIApplication.shared.connectedScenes as NSSet
            let windowScene:UIWindowScene = set.anyObject() as! UIWindowScene
            let window = windowScene.windows.first
            return window?.safeAreaInsets.bottom ?? 20.0
        }
        return 0.0
    }
    
    //计算字符串宽高
    static func calculateTextSize(_ text:String,size:CGSize,font:UIFont) -> CGSize  {
        let rect: CGRect = text.boundingRect(with: size, options: NSStringDrawingOptions.init(rawValue: 0) , attributes: [NSAttributedString.Key.font:font], context: nil) as CGRect
        return rect.size
    }
    
}

let kLastVersionKey = "kLastVersionKey"
let kTokenExpDateTime = "kTokenExpDateTime"
let kADLaunchCacheKey = "kADLaunchCacheKey"
let kHostSearchCacheKey = "kHostSearchCacheKey"
 
